home *** CD-ROM | disk | FTP | other *** search
- /*
- File: PMUtilities.c
-
- Contains: QuickTime sample code
-
- Copyright: © 2000 by Apple Computer, Inc. All rights reserved
-
-
- */
-
- #include <MacTypes.h>
- #include <Gestalt.h>
- #include <Movies.h>
- #include "ComFramework.h"
- #include "MacFramework.h"
- #include "PMUtilities.h"
-
- // Global UPP for PrePreroll
- // A routine descriptor for our pre-preroll completion routine
- MoviePrePrerollCompleteUPP gMoviePPRollCompleteProc = NULL;
-
- //////////
- //
- // QTIsQuickTimeInstalled
- // Is QuickTime installed?
- //
- //////////
-
- Boolean IsQuickTimeInstalled (void)
- {
-
- // Insert IsQuickTimeInstalled.clp here...
-
- return(myErr == noErr);
- }
-
-
- //////////
- //
- // QTQuickTimeCFMInstalled
- // Are the QuickTime CFM libraries installed?
- //
- //////////
-
- #if TARGET_CPU_PPC
- Boolean IsQuickTimeCFMInstalled (void)
- {
- Boolean myQTCFMAvail = false;
- long myAttrs;
- OSErr myErr = noErr;
-
- // Test whether the PowerPC QuickTime glue library is present
-
- // Insert IsQuickTimeCFMInstalled.clp here...
-
-
- // Test whether a function is available (the library is not moved from the Extension folder);
- // This is the trick to be used when testing if a function is available via CFM
- if (!CompressImage)
- myQTCFMAvail = false;
-
- return(myQTCFMAvail);
- }
- #endif
-
- void DoInitQuickTime( void )
- {
- OSErr myErr;
-
- // Insert EnterMovies.clp here...
-
-
- if (myErr != noErr) {
- QTFrame_ShowWarning("\pCould not initialize QuickTime. Exiting.", myErr);
- ExitToShell();
- }
-
- gMoviePPRollCompleteProc = NewMoviePrePrerollCompleteProc(MoviePrePrerollCompleteProc);
-
- return;
- }
-
- //////////
- //
- // GetWindowPositionFromFile
- // Return, through thePoint, the stored position of the specified movie.
- //
- // Return an error if the movie has no stored position. In any case, return a meaningful position.
- //
- //////////
-
- OSErr GetWindowPositionFromFile (Movie theMovie, Point *thePoint)
- {
- UserData myUserData = NULL;
- Point myPoint = {kDefaultWindowX, kDefaultWindowY};
- OSErr myErr = paramErr;
-
- if (theMovie == NULL)
- goto bail;
-
- // get the movie's user data list
-
- // Step 1.
- // Insert GetMovieUserData.clp here...
-
-
- if (myUserData != NULL) {
- // Step 2.
- // Insert GetUserDataItem.clp here...
-
-
- if (myErr == noErr) {
- // Endian Flipping Big to Native - This will do the right thing on Windows
- myPoint.v = EndianS16_BtoN(myPoint.v);
- myPoint.h = EndianS16_BtoN(myPoint.h);
- }
- }
-
- bail:
- *thePoint = myPoint;
-
- return(myErr);
- }
-
- //////////
- //
- // MoviePrePrerollCompleteProc
- // A completion procedure for preprerolling movies.
- //
- // The theRefCon parameter is assumed to be a window object.
- //
- //////////
-
- PASCAL_RTN void MoviePrePrerollCompleteProc (Movie theMovie, OSErr thePrerollErr, void *theRefCon)
- {
- #pragma unused(thePrerollErr)
-
- WindowObject myWindowObject = (WindowObject)theRefCon;
-
- if ((theMovie == NULL) || (myWindowObject == NULL))
- return;
-
- // Insert PrerollComplete.clp here...
-
- }
-
- //////////
- //
- // Preroll
- //
- // Preroll the movie, so that it's ready to play when we call StartMovie
- //
- //////////
-
- void PrerollAndPlay( Movie theMovie )
- {
-
- // Insert Preroll.clp here...
-
- }
-
- //////////
- //
- // StartPlayingMovie
- // If the movie is at the end it will take it back to the beginning then start playing it.
- //
- //////////
-
- void StartPlayingMovie(Movie theMovie, Fixed thePlayRate)
- {
-
- long theLoopingInfo;
- QTUtils_GetMovieFileLoopingInfo(theMovie, &theLoopingInfo);
- if(theLoopingInfo == kNoLooping)
- if(GetMovieTime(theMovie, NULL) == GetMovieDuration(theMovie) && !QTUtils_IsStreamedMovie(theMovie))
- GoToBeginningOfMovie(theMovie);
-
- // Insert StartMovie.clp here...
-
- }